Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(autoware_utils): address self-intersecting polygons in random_concave_generator and handle empty inners() during triangulation #8995

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mraditya01
Copy link
Contributor

@mraditya01 mraditya01 commented Oct 1, 2024

Description

Fix two issues in autoware_utils:

  • Self-intersecting polygons in random_concave_generator: fix is_valid function to properly validate inserted edges.

  • Handling empty inners() during triangulation: ensures that empty inners() are properly handled in the triangulation process.

Related links

How was this PR tested?

  • Unit test on self- intersecting polygon and polygon with empty inners().
colcon test --packages-select autoware_universe_utils
  • Before fix on added test for polygon with empty inner:
> terminate called after throwing an instance of 'std::bad_optional_access'
  what():  bad optional access
[ros2run]: Aborted
  • After fix on added test for polygon with empty inner:
[ RUN      ] geometry.PolygonTriangulation
[       OK ] geometry.PolygonTriangulation (0 ms)

Notes for reviewers

None.

Interface changes

None.

Effects on system behavior

None.

@github-actions github-actions bot added the component:common Common packages from the autoware-common repository. (auto-assigned) label Oct 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@mraditya01 mraditya01 changed the title fix(autoware_utils): Address self-intersecting polygons in random_concave_generator and handle empty inners() during triangulation fix(autoware_utils): address self-intersecting polygons in random_concave_generator and handle empty inners() during triangulation Oct 1, 2024
@mraditya01 mraditya01 marked this pull request as ready for review October 1, 2024 06:32
double x3 = points[2].x();
double y3 = points[2].y();

return std::abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a source for this formula ?
Or if this function is only needed for the test then just use boost::geometry::area in the tests.

return std::abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}

double calculate_total_triangle(const std::vector<autoware::universe_utils::Polygon2d> & triangles)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name of this function is not clear.
I also think it only needs to be defined in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will move the function to test and use boost::geometry::area instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:common Common packages from the autoware-common repository. (auto-assigned)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants